$(document).ready(function(){
	window.newNumber = $("#countsNext").text();
	var numberLengh = $("#countsNext").text().length;
	console.log(numberLengh)
		
	$(window).scroll(function() {
		var shareSection = $('.network').offset();
		if ( $(document).scrollTop() >= shareSection.top - $(window).height()+1200){
			$(".impressions").addClass("visible")
			$("#counts").animateNumber(window.newNumber,{easing:"easeInOutCirc",duration:1000});
		}		
	});

	$("#ajax-contact-form-one").submit(function() {
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "http://fusionads.net/form/includes/contact-process.php",
			data: str,
			success: function(msg) {
    			if(msg == 'OK') {
    				result = '<div class="notification_ok"><h4>Got your email.</h4><span>Thanks!</span><p>We will respond as quickly as possible, and almost always in less than 24 hours.</p></div>';
    				$("#fields_contact_one").hide();
    			} else {
    				result = msg;
    			}
    			$('#notes_contact_one').html(result);
			}
		});
		return false;
	});
	$("#ajax-contact-form-two").submit(function() {
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "http://fusionads.net/form/includes/contact-process.php",
			data: str,
			success: function(msg) {
    			if(msg == 'OK') {
    				result = '<div class="notification_ok"><h4>Got your email.</h4><b></b><span>Thanks!</span><p>We will respond as quickly as possible, and almost always in less than 24 hours.</p><b></b></div>';
    				$("#fields_contact_two").hide();
    			} else {
    				result = msg;
    			}
    			$('#notes_contact_two').html(result);
			}
		});
		return false;
	});
	$("#ajax-contact-form-three").submit(function() {
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "http://fusionads.net/form/includes/contact-process.php",
			data: str,
			success: function(msg) {
    			if(msg == 'OK') {
    				result = '<div class="notification_ok"><h4>Got your email.</h4><span>Thanks!</span><p>We will respond as quickly as possible, and almost always in less than 24 hours.</p></div>';
    				$("#fields_contact_three").hide();
    			} else {
    				result = msg;
    			}
    			$('#notes_contact_three').html(result);
			}
		});
		return false;
	});
	$("#ajax-contact-form-four").submit(function() {
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "http://fusionads.net/form/includes/contact-process.php",
			data: str,
			success: function(msg) {
    			if(msg == 'OK') {
    				result = '<div class="notification_ok"><h4>Got your email.</h4><span>Thanks!</span><p>We will respond as quickly as possible, and almost always in less than 24 hours.</p></div>';
    				$("#fields_contact_four").hide();
    			} else {
    				result = msg;
    			}
    			$('#notes_contact_four').html(result);
			}
		});
		return false;
	});
	$("#ajax-contact-form-five").submit(function() {
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "http://fusionads.net/form/includes/suggest-process.php",
			data: str,
			success: function(msg) {
    			if(msg == 'OK') {
    				result = '<div class="notification_ok"><h4>Got your email.</h4><span>Thanks!</span><p>We will respond as quickly as possible, and almost always in less than 24 hours.</p></div>';
    				$("#fields_contact_five").hide();
    			} else {
    				result = msg;
    			}
    			$('#notes_contact_five').html(result);
			}
		});
		return false;
	});
	$("#ajax-contact-form-six").submit(function() {
		var str = $(this).serialize();
		$.ajax({
			type: "POST",
			url: "http://fusionads.net/form/includes/shirt-process.php",
			data: str,
			success: function(msg) {
    			if(msg == 'OK') {
    				result = '<div class="notification_ok"><h4>Got your email.</h4><span>Thanks!</span><p>We will respond as quickly as possible, and almost always in less than 24 hours.</p></div>';
    				$("#fields_contact_six").hide();
    			} else {
    				result = msg;
    			}
    			$('#notes_contact_six').html(result);
			}
		});
		return false;
	});
});

$(document).ready(function(){
    $(".error_name").show();
    $("#errname_one").focusin(function() {
        $(".error_name").fadeOut();
        $("#errname_one").removeClass('errfield');
    });	
    $(".error_email").show();
    $("#erremail_one").focusin(function() {
        $(".error_email").fadeOut();
        $("#erremail_one").removeClass('errfield');
    });
    $(".error_message").show();
    $("#errmessage_one").focusin(function() {
        $(".error_message").fadeOut();
        $("#errmessage_one").removeClass('errfield');
    });
    $(".error_name").show();
    $("#errname_two").focusin(function() {
        $(".error_name").fadeOut();
        $("#errname_two").removeClass('errfield');
    });
    $(".error_email").show();
    $("#erremail_two").focusin(function() {
        $(".error_email").fadeOut();
        $("#erremail_two").removeClass('errfield');
    });
    $(".error_message").show();
    $("#errmessage_two").focusin(function() {
        $(".error_message").fadeOut();
        $("#errmessage_two").removeClass('errfield');
    });
    $(".error_name").show();
    $("#errname_three").focusin(function() {
        $(".error_name").fadeOut();
        $("#errname_three").removeClass('errfield');
    });
    $(".error_email").show();
    $("#erremail_three").focusin(function() {
        $(".error_email").fadeOut();
        $("#erremail_three").removeClass('errfield');
    });
    $(".error_message").show();
    $("#errmessage_three").focusin(function() {
        $(".error_message").fadeOut();
        $("#errmessage_three").removeClass('errfield');
    });
    $(".error_name").show();
    $("#errname_four").focusin(function() {
        $(".error_name").fadeOut();
        $("#errname_four").removeClass('errfield');
    });
    $(".error_email").show();
    $("#erremail_four").focusin(function() {
        $(".error_email").fadeOut();
        $("#erremail_four").removeClass('errfield');
    });
    $(".error_message").show();
    $("#errmessage_four").focusin(function() {
        $(".error_message").fadeOut();
        $("#errmessage_four").removeClass('errfield');
    });
    $(".error_name").show();
    $("#errname_five").focusin(function() {
        $(".error_name").fadeOut();
        $("#errname_five").removeClass('errfield');
    });
    $(".error_email").show();
    $("#erremail_five").focusin(function() {
        $(".error_email").fadeOut();
        $("#erremail_five").removeClass('errfield');
    });
    $(".error_website").show();
    $("#errwebsite_five").focusin(function() {
        $(".error_website").fadeOut();
        $("#errwebsite_five").removeClass('errfield');
    });
	$(".error_message").show();
    $("#errmessage_five").focusin(function() {
        $(".error_message").fadeOut();
        $("#errmessage_five").removeClass('errfield');
    });
	$(".error_size").show();
    $("#errsize_six").focusin(function() {
        $(".error_size").fadeOut();
        $("#errsize_six").removeClass('errfield');
    });
	$(".error_namefield").show();
    $("#errnamefield_six").focusin(function() {
        $(".error_namefield").fadeOut();
        $("#errnamefield_six").removeClass('errfield');
    });
	$(".error_emailfield").show();
    $("#erremailfield_six").focusin(function() {
        $(".error_emailfield").fadeOut();
        $("#erremailfield_six").removeClass('errfield');
    });
	$(".error_mailingaddress").show();
    $("#errmailingaddress_six").focusin(function() {
        $(".error_mailingaddress").fadeOut();
        $("#errmailingaddress_six").removeClass('errfield');
    });
	$(".error_city").show();
    $("#errcity_six").focusin(function() {
        $(".error_city").fadeOut();
        $("#errcity_six").removeClass('errfield');
    });
	$(".error_state").show();
    $("#errstate_six").focusin(function() {
        $(".error_state").fadeOut();
        $("#errstate_six").removeClass('errfield');
    });
	$(".error_zip").show();
    $("#errzip_six").focusin(function() {
        $(".error_zip").fadeOut();
        $("#errzip_six").removeClass('errfield');
    });
	$(".error_country").show();
    $("#errcountry_six").focusin(function() {
        $(".error_country").fadeOut();
        $("#errcountry_six").removeClass('errfield');
    });
	$(".error_messagefield").show();
    $("#errmessagefield_six").focusin(function() {
        $(".error_messagefield").fadeOut();
        $("#errmessagefield_six").removeClass('errfield');
    });
	$(".closeit").click(function() {
        $(".error_name").hide();
        $(".error_email").hide();
        $(".error_message").hide();
        $("#errname_one").removeClass('errfield');
        $("#erremail_one").removeClass('errfield');
        $("#errmessage_one").removeClass('errfield');
        $("#errname_two").removeClass('errfield');
        $("#erremail_two").removeClass('errfield');
        $("#errmessage_two").removeClass('errfield');
        $("#errname_three").removeClass('errfield');
        $("#erremail_three").removeClass('errfield');
        $("#errmessage_three").removeClass('errfield');
        $("#errname_four").removeClass('errfield');
        $("#erremail_four").removeClass('errfield');
        $("#errmessage_four").removeClass('errfield');
        $("#errname_five").removeClass('errfield');
        $("#erremail_five").removeClass('errfield');
        $("#errwebsite_five").removeClass('errfield');
        $("#errmessage_five").removeClass('errfield');
        $("#errsize_six").removeClass('errfield');
        $("#errnamefield_six").removeClass('errfield');
        $("#erremailfield_six").removeClass('errfield');
        $("#errmailingaddress_six").removeClass('errfield');
        $("#errcity_six").removeClass('errfield');
        $("#errstate_six").removeClass('errfield');
        $("#errzip_six").removeClass('errfield');
        $("#errcountry_six").removeClass('errfield');
        $("#errmessagefield_six").removeClass('errfield');
    });
	$(".flipit").click(function() {
        $(".error_name").hide();
        $(".error_email").hide();
        $(".error_message").hide();
        $("#errname_one").removeClass('errfield');
        $("#erremail_one").removeClass('errfield');
        $("#errmessage_one").removeClass('errfield');
        $("#errname_two").removeClass('errfield');
        $("#erremail_two").removeClass('errfield');
        $("#errmessage_two").removeClass('errfield');
        $("#errname_three").removeClass('errfield');
        $("#erremail_three").removeClass('errfield');
        $("#errmessage_three").removeClass('errfield');
        $("#errname_four").removeClass('errfield');
        $("#erremail_four").removeClass('errfield');
        $("#errmessage_four").removeClass('errfield');
        $("#errname_five").removeClass('errfield');
        $("#erremail_five").removeClass('errfield');
        $("#errwebsite_five").removeClass('errfield');
        $("#errmessage_five").removeClass('errfield');
        $("#errsize_six").removeClass('errfield');
        $("#errnamefield_six").removeClass('errfield');
        $("#erremailfield_six").removeClass('errfield');
        $("#errmailingaddress_six").removeClass('errfield');
        $("#errcity_six").removeClass('errfield');
        $("#errstate_six").removeClass('errfield');
        $("#errzip_six").removeClass('errfield');
        $("#errcountry_six").removeClass('errfield');
        $("#errmessagefield_six").removeClass('errfield');
    });
});



$(function(){

	$('#team').boutique({
		front_img_width:	125,
		front_img_height:	151,
		autoplay:			true,
		behind_size:		.66,
		back_size:			.66,
		behind_distance:	95,
		behind_opacity:		0.4,
		back_opacity:		0.4,
		hovergrowth:		0,
		move_more_directly: true,
		text_opacity:		1
	});
	
	$('.carousel .left, #next').click(function() {
		$('.frame5').trigger("click");
	});
	$('.carousel .right').click(function() {
		$('.frame1').trigger("click");
		return false;
	});
	$(document).on('click', ".boutique .frame3", function () {
		return false;
	});


});

function move_callback(anchor, instanceid){
	if(instanceid === 'team'){
    animationSpeed = 200
    phrase = $(".text").children().eq(anchor-1).html();
    $('.term-one').animate({ 'opacity': 0 }, animationSpeed, function(){
      $('.term-one').css({ 'width': $('.term-one').width() });
      $('.description h3').append($('<span class="temp one">' + phrase + '</span>'));
      $('.term-one').animate({ 'width': $('.description h3 .temp.one').width() }, animationSpeed, function(){
        $('.temp.one').remove();
        $('.term-one').html(phrase);
        $('.term-one').animate({ 'opacity': 1 }, animationSpeed, function(){
          $('.term-one').width('auto');
        });
      });
    });
	}
}

$(window).scroll(function() {
	if ($(document).scrollTop() > 90) {
		$('li.btn').addClass('fill');
		$('.header').addClass('shadow');
	} else {
		$('li.btn').removeClass('fill');
		$('.header').removeClass('shadow');
	}
});
$(function () {
	$('.flipit').click(function() {
		$(this).hide();
		$('.flipme').hide();
		$('.flipit').not($(this)).show().addClass("opacity");
		$('.flipme').eq($(this).data('rel')).show();
	});
	$(".closeit").click(function(){
	  $(".flipit").removeClass("opacity");
	});
});

(function(){
	var fusion = document.createElement('script');
	fusion.src = window.location.protocol + '//adn.fusionads.net/api/1.0/ad.js?zoneid=12&rand=' + Math.floor(Math.random()*99999);
	fusion.async = true;
	(document.head || document.getElementsByTagName('head')[0]).appendChild(fusion);
})();